package com.hsteach.web.controller.visit.sdk;

import com.hsteach.common.annotation.Anonymous;
import com.hsteach.common.core.controller.BaseController;
import com.hsteach.common.core.domain.AjaxResult;
import com.hsteach.common.core.page.TableDataInfo;
import com.hsteach.service.visit.VisitSdkService;
import com.hsteach.web.controller.visit.sdk.dto.ListFamilyDto;
import com.hsteach.web.controller.visit.sdk.dto.SdkListRecordDto;
import com.hsteach.web.controller.visit.sdk.dto.SdkRecordDetailDto;
import com.hsteach.web.controller.visit.sdk.dto.SumRecordDto;
import com.hsteach.web.controller.visit.sdk.vo.SdkFamilyVo;
import com.hsteach.web.controller.visit.sdk.vo.SdkListRecordVo;
import com.hsteach.web.controller.visit.sdk.vo.SumRecordVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 家访外部接口
 * 
 * @author fanxquer
 * @date 2023-07-07
 */
@Api(value = "家访外部接口", tags = "家访外部接口")
@RestController
@RequestMapping("/sdk/visit")
public class VisitSdkController extends BaseController
{
    @Autowired
    private VisitSdkService visitSdkService;

    /**
     * 查询家访总数
     */
    @ApiOperation("查询家访总数")
    @Anonymous
    @PostMapping("/sumRecord")
    public AjaxResult sumRecord(HttpServletRequest request, @RequestBody @Validated SumRecordDto dto)
    {
        Long aLong = visitSdkService.sumRecord(dto.getOrgCode());
        SumRecordVo vo = new SumRecordVo();
        vo.setSumRet(aLong);
        return AjaxResult.success(vo);
    }

    /**
     * 查询家访总数
     */
    @ApiOperation("分页查询家访记录")
    @Anonymous
    @PostMapping("/pageQuery")
    public TableDataInfo<SdkListRecordVo> pageQuery(HttpServletRequest request, @RequestBody @Validated SdkListRecordDto dto)
    {
        return visitSdkService.pageQuery(dto);
    }

    /**
     * 查询家访记录详情
     */
    @ApiOperation("查询家访记录详情")
    @Anonymous
    @PostMapping("/detail")
    public AjaxResult detail(HttpServletRequest request, @RequestBody @Validated SdkRecordDetailDto dto)
    {
        return AjaxResult.success(visitSdkService.detail(dto.getRecordId()));
    }

    /**
     * 查询家访记录详情
     */
    @ApiOperation("查询家庭信息列表")
    @Anonymous
    @PostMapping("/family/list")
    public TableDataInfo<SdkFamilyVo> listFamily(HttpServletRequest request, @RequestBody @Validated ListFamilyDto dto)
    {
        return getDataTable(visitSdkService.listFamily(dto.getPersonIds(), dto.getStructures(), dto.getOrgCode()));
    }

}
